package com.hopes.bizz.risk.transfer.converter;

import com.hopes.bizz.risk.control.entity.RiskUnitEntity;
import com.hopes.bizz.risk.transfer.bean.dto.RiskUnitDto;
import org.mapstruct.BeanMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

@Mapper
public interface RiskUnitConverter {
    RiskUnitConverter INSTANCE = Mappers.getMapper(RiskUnitConverter.class);

    @Mapping(target = "uid", source = "id")
    @Mapping(target = "delFlag", source = "deleted", defaultValue = "0")
    @Mapping(target = "createTime", source = "createDate", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(target = "createBy", source = "createBy")
    @Mapping(target = "updateTime", source = "updateDate", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(target = "updateBy", source = "updateBy")
    @Mapping(target = "riskName", source = "riskUnitName")
    @Mapping(target = "dept", source = "hazardDep")
    @Mapping(target = "principal", source = "hazardLiablePerson")
    @BeanMapping(ignoreByDefault = true)
    RiskUnitEntity toEntity(RiskUnitDto riskUnitDto);
}
